﻿// Decompiled by AS3 Sorcerer 6.78
// www.buraks.com/as3sorcerer

//com.wdcgame.engine.nape.utils.BodyDataTransUtil

package com.game.engine.nape.utils
{
    import com.game.tile.model.ObjectLayerVO

    public class BodyDataTransUtil 
    {


        public static function createByTmx(_arg_1:ObjectLayerVO, _arg_2:int):Array
        {
            var _local_13:* = null;
            var _local_10:int;
            var _local_12:* = null;
            var _local_6:Number;
            var _local_4:Number;
            var _local_8:Number;
            var _local_5:Number;
            var _local_7:Number;
            var _local_14:Number;
            var _local_9:* = null;
            var _local_11:* = null;
            var _local_3:Array = [];
            _local_10 = 0;
            while (_local_10 < _arg_1.objects.length)
            {
                _local_12 = _arg_1.objects[_local_10];
                _local_12.x = (_local_12.x * _arg_2);
                _local_12.y = (_local_12.y * _arg_2);
                _local_12.width = (_local_12.width * _arg_2);
                _local_12.height = (_local_12.height * _arg_2);
                if (_local_12.name == "")
                {
                    _local_12.name = _arg_1.name.toLowerCase();
                }
                _local_6 = _local_12.properties.density;
                if (isNaN(_local_6))
                {
                    _local_6 = 1;
                }
                _local_4 = _local_12.properties.elasticity;
                if (isNaN(_local_4))
                {
                    _local_4 = 0;
                }
                _local_8 = _local_12.properties.staticFriction;
                if (isNaN(_local_8))
                {
                    _local_8 = 2;
                }
                _local_5 = _local_12.properties.dynamicFriction;
                if (isNaN(_local_5))
                {
                    _local_5 = 1;
                }
                _local_7 = _local_12.properties.rollingFriction;
                if (isNaN(_local_7))
                {
                    _local_7 = 0.001;
                }
                _local_14 = _local_12.properties.collisionMask;
                if (isNaN(_local_14))
                {
                    _local_14 = -1;
                }
                _local_9 = "Polygon";
                if (_local_12.ellipse)
                {
                    _local_9 = "Circle";
                }
                _local_11 = "st";
                if (_local_12.properties.bodyType)
                {
                    _local_11 = _local_12.properties.bodyType;
                }
                switch (_local_12.type)
                {
                    case "ground":
                        _local_13 = {
                            "py":_local_12.y,
                            "height":_local_12.height,
                            "allowRotation":0,
                            "label":_local_12.name,
                            "shapeType":_local_9,
                            "collisionGroup":0x0100,
                            "bodyType":_local_11,
                            "material":{
                                "density":_local_6,
                                "elasticity":_local_4,
                                "staticFriction":_local_8,
                                "dynamicFriction":_local_5,
                                "rollingFriction":_local_7
                            },
                            "px":_local_12.x,
                            "collisionMask":-1,
                            "width":_local_12.width,
                            "sensorEnabled":0
                        };
                        _local_3.push(_local_13);
                        break;
                    case "wall":
                        _local_13 = {
                            "py":_local_12.y,
                            "height":_local_12.height,
                            "allowRotation":0,
                            "label":"wall",
                            "shapeType":"Polygon",
                            "collisionGroup":0x0400,
                            "bodyType":"st",
                            "material":{
                                "density":_local_6,
                                "elasticity":_local_4,
                                "staticFriction":_local_8,
                                "dynamicFriction":_local_5,
                                "rollingFriction":_local_7
                            },
                            "px":_local_12.x,
                            "collisionMask":-1,
                            "width":_local_12.width
                        };
                        _local_3.push(_local_13);
                        break;
                    case "floor":
                        _local_13 = {
                            "py":_local_12.y,
                            "height":_local_12.height,
                            "allowRotation":0,
                            "label":"floor",
                            "shapeType":"Polygon",
                            "collisionGroup":CollisionGroup.FLOOR,
                            "bodyType":"st",
                            "material":{
                                "density":_local_6,
                                "elasticity":_local_4,
                                "staticFriction":_local_8,
                                "dynamicFriction":_local_5,
                                "rollingFriction":_local_7
                            },
                            "px":_local_12.x,
                            "collisionMask":-1,
                            "width":_local_12.width
                        };
                        _local_3.push(_local_13);
                        break;
                    case "dead":
                        _local_13 = {
                            "py":_local_12.y,
                            "height":_local_12.height,
                            "allowRotation":0,
                            "label":"floor",
                            "shapeType":"Polygon",
                            "collisionGroup":0x10000,
                            "bodyType":"st",
                            "material":{
                                "density":_local_6,
                                "elasticity":_local_4,
                                "staticFriction":_local_8,
                                "dynamicFriction":_local_5,
                                "rollingFriction":_local_7
                            },
                            "px":_local_12.x,
                            "collisionMask":-1,
                            "width":_local_12.width
                        };
                        _local_3.push(_local_13);
                        break;
                    case "ceiling":
                        _local_13 = {
                            "py":_local_12.y,
                            "height":_local_12.height,
                            "allowRotation":0,
                            "label":"ceiling",
                            "shapeType":"Polygon",
                            "collisionGroup":CollisionGroup.CEILING,
                            "bodyType":"st",
                            "material":{
                                "density":_local_6,
                                "elasticity":_local_4,
                                "staticFriction":_local_8,
                                "dynamicFriction":_local_5,
                                "rollingFriction":_local_7
                            },
                            "px":_local_12.x,
                            "collisionMask":-1,
                            "width":_local_12.width
                        };
                        _local_3.push(_local_13);
                        break;
                    case "medge":
                        _local_14 = 128;
                        _local_13 = {
                            "py":_local_12.y,
                            "height":_local_12.height,
                            "allowRotation":0,
                            "label":"medge",
                            "shapeType":"Polygon",
                            "collisionGroup":0x2000,
                            "bodyType":_local_11,
                            "material":{
                                "density":_local_6,
                                "elasticity":_local_4,
                                "staticFriction":_local_8,
                                "dynamicFriction":_local_5,
                                "rollingFriction":_local_7
                            },
                            "px":_local_12.x,
                            "collisionMask":_local_14,
                            "width":_local_12.width,
                            "collisionMask2":_local_12.properties.collisionMask2
                        };
                        _local_3.push(_local_13);
                        break;
                    case "redge":
                        _local_14 = 2;
                        _local_13 = {
                            "py":_local_12.y,
                            "height":_local_12.height,
                            "allowRotation":0,
                            "label":"wall",
                            "shapeType":"Polygon",
                            "collisionGroup":0x4000,
                            "bodyType":"st",
                            "material":{
                                "density":_local_6,
                                "elasticity":_local_4,
                                "staticFriction":_local_8,
                                "dynamicFriction":_local_5,
                                "rollingFriction":_local_7
                            },
                            "px":_local_12.x,
                            "collisionMask":_local_14,
                            "width":_local_12.width
                        };
                        _local_3.push(_local_13);
                        break;
                    default:
                        _local_13 = {
                            "py":_local_12.y,
                            "height":_local_12.height,
                            "allowRotation":0,
                            "label":"wall",
                            "shapeType":_local_9,
                            "collisionGroup":0x4000,
                            "bodyType":"st",
                            "material":{
                                "density":_local_6,
                                "elasticity":_local_4,
                                "staticFriction":_local_8,
                                "dynamicFriction":_local_5,
                                "rollingFriction":_local_7
                            },
                            "px":_local_12.x,
                            "collisionMask":_local_14,
                            "width":_local_12.width
                        };
                        _local_3.push(_local_13);
                }
                _local_13.objectVo = _local_12;
                _local_10++;
            }
            return (_local_3);
        }


    }
}//package com.wdcgame.engine.nape.utils

